import { legacy_createStore as createStore } from 'redux'
import { persistStore, persistReducer } from 'redux-persist'
import storage from 'redux-persist/lib/storage'
// 根据 reducer 创建 store
import rootReducer from './reducers'
const persistConfig = {
  key: 'root', // key 是存储在 localStorage 中的 key
  storage,
}
const persistedReducer = persistReducer(persistConfig, rootReducer)
export const store = createStore(persistedReducer)
export const persistor = persistStore(store)
